package org.ahuanlien.crm.web.controller;

import org.ahuanlien.crm.domain.CaseReportBillItem;
import org.ahuanlien.crm.query.CaseReportBillItemQueryObject;
import org.ahuanlien.crm.service.ICaseReportBillItemService;
import org.ahuanlien.crm.util.JSONResult;
import org.ahuanlien.crm.util.LogicException;
import org.ahuanlien.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("caseReportBillItem")
public class CaseReportBillItemController {

	@Autowired
	private ICaseReportBillItemService caseReportBillItemService;

	@RequestMapping("view")
	public String view() {
		return "caseReportBillItem/view";
	}

	@RequestMapping("query")
	@ResponseBody
	public PageResult query(CaseReportBillItemQueryObject qo) {
		PageResult result = caseReportBillItemService.query(qo);
		return result;
	}

	@RequestMapping("queryByCaseNumber")
	@ResponseBody
	public CaseReportBillItem queryByCaseNumber(String caseNumber) {

		return caseReportBillItemService.getByCaseNumber(caseNumber);
	}

	@RequestMapping("saveOrUpdate")
	@ResponseBody
	public JSONResult saveOrUpdate(CaseReportBillItem caseReportBill) {
		try {
			caseReportBillItemService.saveOrUpdate(caseReportBill);
		} catch (LogicException e) {
			e.printStackTrace();
			return JSONResult.mark(e.getMessage());
		}
		return JSONResult.success("操作成功");
	}
}
